let { getTaskInfo, getProjectList,rwJdNum } = require("../../../api/programs/forward");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    rwjds:{},
    timeDown:true,
    xmmc: "",
    INFO: wx.getStorageSync("userInfoMy"),
    yxs: null,
    cqs: null,
    query: {
      name: null,
      id: null,
      type: 77,
    },
    projectList: {},
    projectListCQ: [],
    // result: ["TK", "PG", "GJ", "FP"],
  },
  checkTime(){
    this.setData({
      timeDown:!this.data.timeDown
    })
    this.getProjectListAll()
  },
  onChangeCheck(event) {
    console.log(event.detail)
    this.setData({
      result: event.detail,
    });
    this.getProjectListAll();
  },
  onChange(e) {
    this.setData({
      xmmc: e.detail,
    });
  },
  onSearch() {
    this.getProjectListAll();
  },
  onClick() {
    this.getProjectListAll();
  },

  getProjectListAll() {
    this.setData({
      INFO: wx.getStorageSync("userInfoMy"),
    });
    wx.showLoading({
      title: "加载中",
    }); 
    // let checkNo=  this.data.result.join()
    rwJdNum(this.data.INFO.jname).then(res=>{
      this.setData({
        rwjds:res.data[0]
      })
    })
    setTimeout(() => {
      getProjectList({
        type: 77,
        name: this.data.INFO.jname,
        id: this.data.INFO.id,
        rybh: this.data.INFO.rybh,
        xmmc: this.data.xmmc,
        // checkStatus:checkNo
        timeDown:this.data.timeDown
      }).then((res) => {
        console.log(res.data);
        this.setData({
          projectList: res.resultData,
        });
      });
      getProjectList({
        type: 87,
        name: this.data.INFO.jname,
        id: this.data.INFO.id,
        rybh: this.data.INFO.rybh,
        xmmc: this.data.xmmc,
        timeDown:this.data.timeDown


      }).then((res) => {
        this.setData({
          projectListCQ: res.data,
        });
        wx.hideLoading();
      });

      getTaskInfo({
        rwr: this.data.INFO.jname,
        rybh: this.data.INFO.rybh,
      }).then((res) => {
        this.setData({
          yxs: res[0].yxs,
          cqs: res[0].cqs,
        });
      });
      wx.hideLoading();
    }, 500);
    console.log(this.data.INFO);
  },
  goDetail(e) {
    const { xmbh, rwbsh, xmzbh, xmzname } = e.currentTarget.dataset;
    wx.setStorageSync("xmzbh", xmzbh);
    wx.setStorageSync("xmzname", xmzname);

    wx.navigateTo({
      url: `/pages/programs/detail/detail?xmbh=${xmbh}&rwbsh=${rwbsh}`,
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.showLoading({
      title: "加载中",
    }),
      this.getProjectListAll();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    wx.showLoading({
      title: "加载中",
    }),
      this.getProjectListAll();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
    console.log("触发下拉");
    this.getProjectListAll();
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});
